home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK2.toast / Development Kits (Disc 2) / ScriptX / Documentation / Code Examples from Docs / toolguid / dtksampl / myctrans.sx < prev    next >
Encoding:
Text File  |  1996-05-21  |  4.1 KB  |  151 lines  |  [TEXT/ttxt]

  1. --<<<
  2. -- Filename:
  3. --       myCtrans.sx
  4.  
  5. -- Purpose:
  6. --      This file defines a cast translator that
  7. --    prints information about castmembers in a Director file
  8. --    to an output file
  9.  
  10.  
  11. -- Specialized Classes:
  12. --      CastTwoDShape, CastTextPresenter, CastMoviePlayer, 
  13. --    and CastDigitalAudioPlayer are subclasses of TwoDShape,
  14. --    TextPresenter, InterleavedMoviePlayer, and DigitalAudioPlayer
  15. --    respectively. The only thing that is different between the 
  16. --    new subclass and its superclass is that the new subclasses
  17. --    each have a name instance variable.
  18. --    We use the name instance variable to hold the castName
  19. --    of a castmember in a Director castlist.
  20.  
  21. --     The main specialized class is CastToInfoTranslator
  22. --    which defines the translation methods to translate
  23. --    Director castmembers when importing into ScriptX.
  24.  
  25. --     When you create an instance of CastToInfoTranslator,
  26. --     you must:
  27. --    set the shapeClass iv to CastTwoDShape
  28. --    set the textClass iv to CastTexPresenter
  29. --    set the bitmapClass iv to CastTwoDShape
  30. --    set the videoClass iv to CastMoviePlayer
  31.  
  32.  
  33.  
  34. -- Instructions to User:
  35. --      Don't load this file directly.
  36. --    Instead, load converter.sx, which loads this file.
  37. --     converter.sx creates an instance of CastToInfoTranslator
  38. --     and sets its ivs appropriately, then uses it to import
  39. --    a cast list from a Director file
  40.  
  41. -- Author:
  42. --      Jocelyn Becker
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49. in Module myModule
  50.  
  51. class CastTwoDShape (TwoDShape)
  52. instance variables
  53. name
  54. end
  55.  
  56. class CastTextPresenter (TextPresenter)
  57. instance variables
  58. name
  59. end
  60.  
  61. class CastMoviePlayer (InterleavedMoviePlayer)
  62. instance variables
  63. name
  64. end
  65.  
  66. class CastDigitalAudioPlayer (DigitalAudioPlayer)
  67. instance variables
  68. name
  69. end
  70.  
  71. class CastToInfoTranslator (DTKCastMemberToAudioStream, DTKCastMemberToPresenter)
  72. end
  73.  
  74. -- for the CastMemberToInfo translator, need to set the following ivs:
  75. -- bitmapClass := castTwoDShape
  76. -- shapeClass := castTwoDShape
  77. -- textClass := CastTextPresenter
  78. -- videoClass := CastMoviePlayer
  79.  
  80.  
  81. method translateShape self {class CastToInfoTranslator} shapeCast ->
  82. (
  83.     local thePresenter := nextMethod self shapeCast
  84.     thePresenter.name := shapeCast.castName
  85.     
  86.     format self.outputStream "\nCast member at position %1 is a shape named %2. 
  87.     It is being translated to a CastTwoDShape. \n" \
  88.         #(shapeCast.castNumber, shapeCast.castName) #(@unadorned, @unadorned)
  89.     
  90.     -- return the presenter so that it is put in the cast list
  91.     thePresenter
  92. )
  93.  
  94.  
  95. method translateBitMap self {class CastToInfoTranslator} bitmapCast ->
  96. (
  97.     local thePresenter := nextMethod self bitmapCast
  98.     thePresenter.name := bitmapCast.castName
  99.     
  100.     format self.outputStream "\nCast member at position %1 is a bitmap named %2. 
  101.     It is being translated to a CastTwoDShape. \n" \
  102.         #(bitmapCast.castNumber, bitmapCast.castName) #(@unadorned, @unadorned)
  103.     
  104.     -- return the presenter so that it is put in the cast list
  105.     thePresenter
  106. )
  107.  
  108.  
  109. method translateText self {class CastToInfoTranslator} textCast ->
  110. (
  111.     local thePresenter := nextMethod self textCast
  112.     thePresenter.name := textCast.castName
  113.     
  114.     format self.outputStream "\nCast member at position %1 is a text item named %2.
  115.     It is being translated to a CastTextPresenter. \n" \
  116.         #(textCast.castNumber, textCast.castName) #(@unadorned, @unadorned)
  117.     
  118.     -- return the presenter so that it is put in the cast list
  119.     thePresenter
  120. )
  121.  
  122.  
  123. method translateVideo self {class CastToInfoTranslator} videoCast ->
  124. (
  125.     local thePresenter := nextMethod self videoCast
  126.     thePresenter.name := videoCast.castName 
  127.     
  128.     format self.outputStream "\nCast member at position %1 is a video named %2.
  129.     It is being translated to a CastMoviePlayer. \n" \
  130.         #(videoCast.castNumber, videoCast.castName) #(@unadorned, @unadorned)
  131.     -- return the presenter so that it is put in the cast list
  132.     thePresenter
  133. )
  134.  
  135.  
  136. method translateSound self {class CastToInfoTranslator} soundCast ->
  137. (
  138.     local theAudioStream := nextMethod self soundCast
  139.     local thePlayer := new CastDigitalAudioPlayer mediaStream:theAudioStream
  140.     
  141.     format self.outputStream "\nCast member at position %1 is a sound named %2. 
  142.     It is being translated to a cast digital audio player. \n" \
  143.         #(soundCast.castNumber, soundCast.castName) #(@unadorned, @unadorned)
  144.     
  145.     -- return the player so that it is put in the cast list
  146.     thePlayer
  147. )
  148.  
  149.  
  150. -->>>
  151.